// -----------------------------------------------------------------------------
// M A R I T I M E   R E S E A R C H   I N S T I T U T E   N E T H E R L A N D S
// -----------------------------------------------------------------------------
// Copyright (C) December 15, 2009 MARIN - All rights reserved - http://www.marin.nl
// -----------------------------------------------------------------------------
// Program  :
// Module   :
// File     : PulseManager.h
// -----------------------------------------------------------------------------

#ifndef PULSEMANAGER_H
#define	PULSEMANAGER_H

#include <vector>
#include <mml/Vector.h>
#include <mml/Matrix.h>
#include "defines.h"
#include "Array2D.h"

class Geometry;
class Pulse;

/// class for handling all pressure pulses
class PulseManager
{

public:

    PulseManager(int Nx1,
                 int Nx2,
                 REAL dx1,
                 REAL dx2,
                 REAL pstart,
                 bool smoothing);

    virtual ~PulseManager();

    void addPulse(Geometry* pGeometry);

    unsigned int getNumberOfPulses() const;

    Pulse* getPulse(int nr) const;
    
    void setSmoothing(bool on);
    
    void lower(int nr, REAL currenttime);

    void computePulsePattern(REAL currenttime, REAL dt,
                             const Array2D<REAL>* pNetHeight,
                             Array2D<REAL> **ppPressurePattern);

    void getGridProperties(int* pNx1, int* pNx2, REAL* pdx1, REAL* pdx2);

private:

    int m_Nx1; ///< size in points in x1 direction
    int m_Nx2; ///< size in points in x2 direction
    REAL m_dx1; ///< step size in meters in x1 direction
    REAL m_dx2; ///< step size in meters in x2 direction
    REAL m_start; ///< fade-in time of waves
    bool m_smoothing; ///< spatial smoothing of pressure pulses
    std::vector<Pulse*> m_pulses; ///< list of pulses
    Array2D<REAL> m_pulseField; ///< all pulses in field
    Array2D<REAL> m_pulseFieldOld; ///< all pulses in field
};

#endif // PULSEMANAGER_H

